#include<bits/stdc++.h>
using namespace std;
int n,now,i,cnt;
struct node{
	int u,v,w;
}ans[50];
int main(){
	freopen("road.in","r",stdin);
	freopen("road.out","w",stdout);
	scanf("%d",&n);
	if(n==0){
		printf("1 114 0");
		return 0;
	}
	for(i=1;;i++){
		if((1<<(i+1))-1>n) break;
		ans[++cnt]={i,i+1,1<<(i-1)},ans[++cnt]={i,i+1,0};
		now+=1<<(i-1);
	}
	printf("%d ",i+1);
	ans[++cnt]={i,114,1<<(i-1)},ans[++cnt]={i,114,0};
	now+=1<<(i-1),now++;
	for(;i>=1;i--)
		if(now+(1<<(i-1))-1<=n){
			ans[++cnt]={i,114,now};
			now+=1<<(i-1);
		}
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d %d %d\n",ans[i].u,ans[i].v,ans[i].w);
	return 0;
}
